package com.jueming.cashbook.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * 说明：日期处理
 */
public class DateUtil {

	public final static SimpleDateFormat sdfYear = new SimpleDateFormat("yyyy");
	public final static SimpleDateFormat sdfDay = new SimpleDateFormat("yyyy-MM-dd");
	public final static SimpleDateFormat sdfDay2 = new SimpleDateFormat("yyyy/MM/dd");
	public final static SimpleDateFormat sdfDays = new SimpleDateFormat("yyyyMMdd");
	public final static SimpleDateFormat sdfTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	public final static SimpleDateFormat sdfTimes = new SimpleDateFormat("yyyyMMddHHmmss");
	public final static SimpleDateFormat sdfTimes2 = new SimpleDateFormat("yyyyMMdd HH:mm:ss");
	public final static SimpleDateFormat onlyTime = new SimpleDateFormat("HH:mm:ss");
	public final static SimpleDateFormat onlyTimehm = new SimpleDateFormat("HH:mm");

	/**
	 * yyyy-MM-dd HH:mm:ss 格式的Date转String
	 * @param date
	 * @return
	 */
	public static String DateToString(Date date){
		return sdfTime.format(date);
	}

	/**
	 * 指定SimpleDateFormat Date转String
	 * @param date
	 * @param sdf
	 * @return
	 */
	public static String DateToString(Date date,SimpleDateFormat sdf){
		return sdf.format(date);
	}

	/**
	 * 指定String Date转String
	 * @param date
	 * @param sdfStr
	 * @return
	 */
	public static String DateToString(Date date,String sdfStr){
		SimpleDateFormat sdf = new SimpleDateFormat(sdfStr);
		return sdf.format(date);
	}

	public static void main2(String[] args) throws ParseException {

	}
}
